<?php


namespace app\api\validate;


use think\Validate;

class CartValidate extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'goods_id' => ['require', 'gt:0'],
        'goods_spec_id' => ['require', 'gt:0'],
        'num' => ['require', 'gt:0'],
        'cart_ids' => ['require'],
        'cart_id' => ['require', 'gt:0'],
    ];

    /**
     * 提示消息
     */
    protected $message = [];

    /**
     * 验证场景
     */
    protected $scene = [
        'addCart' => ['goods_id', 'goods_spec_id', 'num'],
        'delCartGoods' => ['cart_ids'],
        'editCartGoodsNum' => ['cart_id','num'],
    ];

    public function __construct(array $rules = [], $message = [], $field = [])
    {
        $this->field = [
            'goods_id' => '商品ID',
            'goods_spec_id' => '商品规格ID',
            'num' => '数量',
            'cart_ids' => '购物车ID',
            'cart_id' => '购物车ID',
        ];
        parent::__construct($rules, $message, $field);
    }
}